package com.chenjun.core.dao.generator.mapper;

import com.chenjun.core.dao.generator.entity.SysUserGroup;
import com.chenjun.core.dao.generator.entity.SysUserGroupExample;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

public interface SysUserGroupMapper {
    @Delete({
        "delete from sys_user_group",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String id);

    @Insert({
        "insert into sys_user_group (id, user_id, ",
        "group_id)",
        "values (#{id,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, ",
        "#{groupId,jdbcType=VARCHAR})"
    })
    @SelectKey(statement="SELECT replace(UUID(), '-', '')", keyProperty="id", before=true, resultType=String.class) 
    int insert(SysUserGroup record);

    int insertSelective(SysUserGroup record);

    List<SysUserGroup> selectByExample(SysUserGroupExample example);

    @Select({
        "select",
        "id, user_id, group_id",
        "from sys_user_group",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    @ResultMap("BaseResultMap")
    SysUserGroup selectByPrimaryKey(String id);

    int updateByPrimaryKeySelective(SysUserGroup record);

    @Update({
        "update sys_user_group",
        "set user_id = #{userId,jdbcType=VARCHAR},",
          "group_id = #{groupId,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(SysUserGroup record);
}